#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

#include <iostream>
using namespace std;
const int N = 110;
int n, m1, m2;
int f[N][N];
int main() {
    cin >> n >> m1 >> m2;
    for (int i = 1; i <= n; i++) {
        int w1, w2, v;
        cin >> w1 >> w2 >> v;
        for (int j1 = m1; j1 >= w1; j1--) {
            for (int j2 = m2; j2 >= w2; j2--) f[j1][j2] = max(f[j1][j2], f[j1 - w1][j2 - w2] + v);
        }
    }
    cout << f[m1][m2] << endl;
    return 0;
}